package pl.edu.agh.to1.dice.logic;

import java.lang.StringBuilder;

public class RankingEntry{
	private String name;
	private int sum;
	private int best;
	private int games;

	public RankingEntry(String name){
		this.name = name;
		this.sum = 0;
		this.best = 0;
		this.games = 0;
	}

	public RankingEntry(String name, int sum, int best, int games){
		this.name = name;
		this.sum = sum;
		this.best = best;
		this.games = games;
	}

	public String getName(){
		return name;
	}

	public int getSum(){
		return sum;
	}
	
	public int getBest(){
		return best;
	}

	public int getGames(){
		return games;
	}

	public String toString(){
		StringBuilder strBuilder = new StringBuilder("");
		strBuilder.append(name).append(" ").append(sum).append(" ").append(best).append(" ").append(games);
		return strBuilder.toString();
	}
	
	public void onGameFinish(int result){
		games++;
		if(result > best)
			best = result;
		
		sum += result;
	}
}
